#include <vector>
#include <string>

#include "DTD_Element.h"

using namespace std;

DTD_Element::DTD_Element( string name, DTD_Contenu * content )
{
	this->name = name;
	this->content = content;
	this->attributes = NULL;
}

DTD_Element::DTD_Element( string name )
{
	this->name = name;
	this->content = NULL;
	this->attributes = NULL;
}

DTD_Element::~DTD_Element()
{
	// Suppression des attributs.
    while(!attributes->empty())
    {
        delete attributes->back();
        attributes->pop_back();
    }

    delete attributes;

    delete content;
}

void DTD_Element::addAttributes( vector<DTD_Attribut *> * attributes )
{
	this->attributes = attributes;
}

string DTD_Element::getName()
{
	return name;
}

string DTD_Element::toString()
{
	string R = "";
	if(attributes){
		for (unsigned int i = 0; i < attributes->size(); i++)
		{
		    R += attributes->at(i)->toString();
		    R += "\n";
		}
		return "<!ELEMENT " + name + " " + content->toString() + " >\n" +
				"<!ATTLIST " + name + R + ">\n";
	}
	else{
		return "<!ELEMENT " + name + " " + content->toString() + " >\n";
	}

}


//string DTD_Element::getNom()
//{
//	return nom;
//}
//
//
//vector<DTD_Attribut*> DTD_Element::getAttributList()
//{
//	return attributList;
//}
//
//
//
//DTD_Contenu* DTD_Element::getContenu(){
//	return contenu;
//}
//
//
//void DTD_Element::setAttributList(vector<DTD_Attribut*> attributList){
//	this->attributList = attributList;
//}
//
//void DTD_Element::setContenu(DTD_Contenu* contenu){
//	this->contenu = contenu;
//}
//
//
//void DTD_Element::addAttribut(DTD_Attribut* attribut){
//	attributList.push_back(attribut);
//}
